import { createApp } from "vue";
import { createRouter, createWebHistory } from "vue-router";
import { createStore } from "vuex";
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";
import { registerMicroApps, start } from "qiankun";
import App from "./App.vue";
import routes from "./router";
import store from "./store";

// 创建Vue应用实例
const app = createApp(App);

// 创建路由实例
const router = createRouter({
  history: createWebHistory(),
  routes,
});

// 使用插件
app.use(router);
app.use(store);
app.use(ElementPlus);

// 挂载应用
app.mount("#app");

// 注册微应用
registerMicroApps([
  {
    name: "vue3App",
    entry: "//localhost:3000",
    container: "#subapp-container",
    activeRule: "/vue3",
    props: {
      // 主应用向子应用传递数据
      mainStore: store,
    },
  },
]);

// 启动qiankun, 正常在此处添加可以显示, 但是会造成在子页面刷新的时候报错容纳子应用的容器不存在, 所以start方法最好写到盛放子应用的文件中
// start({
//   sandbox: {
//     experimentalStyleIsolation: true,
//     strictStyleIsolation: true,
//   },
// });
